package com.ternnetwork.core.controller.org;


import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.ternnetwork.commons.model.http.BaseResponse;
import com.ternnetwork.core.entity.org.Department;
import com.ternnetwork.core.service.org.DepartmentService;
import com.ternnetwork.core.ui.DepartmentZtree;





@Controller
@RequestMapping("/core/org/department/*")
public class DepartmentController {
	
	@Resource
	private DepartmentService departmentService;
	
	@RequestMapping("manage.htm")
	public ModelAndView manage(){
		return new ModelAndView("/WEB-INF/view/core/org/department_manage.jsp");
	}
	
	
	@RequestMapping("add.htm")
	public @ResponseBody BaseResponse add(Department t){
		return departmentService.idoAdd(t);
	}
	
	@RequestMapping("update.htm")
	public @ResponseBody BaseResponse update(Department t){
		return departmentService.idoUpdate(t);
	}
	
	@RequestMapping("delete.htm")
	public @ResponseBody BaseResponse delete(Long id){
	   return departmentService.idoDeleteById(id);
	}
	
	@RequestMapping("getZTreeJSON.htm")
	public @ResponseBody List<DepartmentZtree> getZTreeJSON(){
		return departmentService.getZTreeJSON();
	}


}
